<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增医废处置机构、医疗机构关系')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: select2-css"/>

</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-medicalHospitalRelationship-add">
        <!--     医废处置单位列表       -->
       <div class="form-group">
            <label class="col-sm-3 control-label is-required">医废处理单位：</label>
            <div class="col-sm-8">
                <select name="medicalWasteId" class="form-control" th:with="v=${@dep.getYFMedicalWasteList()}" required>
                    <option value="" >&#45;&#45;&#45;&#45;&#45;&#45;请选择医疗废物处置单位&#45;&#45;&#45;&#45;&#45;&#45;</option>
                    <option th:each="l : ${v}" th:text="${l.deptName}" th:value="${l.deptId}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">医疗机构单位：</label>
            <div class="col-sm-8">
                <select name="hospitalId" id="hospitalId" class="form-control" th:with="v=${deptList}" required>
                    <option value="" >------请选择医疗机构------</option>
                    <option th:each="l:${v}" th:text="${l.deptName}" th:value="${l.deptId}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label is-required">开始签约时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="startSigningDate" class="form-control" placeholder="yyyy-MM-dd" type="text"
                        id="startSigningDate"   required>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label is-required">结束签约时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="endSigngingDate" class="form-control" placeholder="yyyy-MM-dd" type="text"
                           required>
                </div>
            </div>
        </div>
        <div class="form-group"  shiro:hasAnyRoles="admin">
            <label class="col-sm-3 control-label">等级类型：</label>
            <div class="col-sm-8">
                <select name="hospType" class="form-control m-b" th:with="type=${@dict.getType('yf_hospital_grade')}"
                        required>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group" shiro:hasAnyRoles="admin">
            <label class="col-sm-3 control-label">删除状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('del_flag')}">
                    <input type="radio" th:id="${'delFlag_' + dict.dictCode}" name="delFlag"
                           th:value="${dict.dictValue}" th:checked="${dict.default}">
                    <label th:for="${'delFlag_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
                    <input type="radio" th:id="${'status_' + dict.dictCode}" name="status"
                           th:value="${dict.dictValue}"
                           th:checked="${dict.default}">
                    <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                </div>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: select2-js"/>
<script type="text/javascript">
    var prefix = ctx + "yf/medicalHospitalRelationship"

    $("#form-medicalHospitalRelationship-add").validate({
        focusCleanup: true,
        rules:{
            "startSigningDate":{
                required: true
            },
            "endSigngingDate": {
                required: true,
                compareDate: "#startSigningDate"
            }
        },messages:{
            "startSigningDate":{
                required: "开始时间不能为空"
            },
            "endSigngingDate":{
                required: "结束时间不能为空",
                compareDate: "结束日期必须大于开始日期!"
            }
        }
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-medicalHospitalRelationship-add').serialize());
        }
    }

    jQuery.validator.methods.compareDate = function(value, element, param) {
        //var startDate = jQuery(param).val() + ":00";补全yyyy-MM-dd HH:mm:ss格式
        //value = value + ":00";

        var startDate = jQuery(param).val();
        var date1 = new Date(Date.parse(startDate.replace("-", "/")));
        var date2 = new Date(Date.parse(value.replace("-", "/")));
        return date1 < date2;
    };

    $("input[name='startSigningDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='endSigngingDate']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>